<?php

class ZFWork_Grid_Deploy_Table extends Bvb_Grid_Deploy_Table {

	private $_boxAlternate = false;
	private $_boxType = 100;
	private $_buttonsHeader = array();
	private $_gridName = '';

	public function deploy() {
		$x = array(
			'boxAlternate' => $this->_boxAlternate,
			'boxType' => $this->_boxType,
			'buttonsHeader' => $this->_buttonsHeader,
			'gridName' => $this->_gridName,
			'content' => parent::deploy(),
		);
		return $x;
	}

	public function addButtonHeader($label, $link) {
		$this->_buttonsHeader[] = array(
			'label' => $label,
			'link' => $link,
		);
	}

	public function addEditButton($linkEdit) {
		$editButton = new Bvb_Grid_Extra_Column();
		$editButton
				->class('editButton')
				->decorator("<a href=\"$linkEdit\"><img src=\"{$this->getImagesUrl()}/pencil.png\"></a>")
				->name('editButton')
				->position('right')
				->title('')
		;
		$this->addExtraColumns($editButton);
	}

	public function addFormatterDir($dir, $prefix) {
		$this->_formatter->addPrefixPath(trim($prefix, '_'), rtrim($dir, '/') . '/');
		return $this;
	}

	public function addTemplateDir($dir, $prefix, $type) {
		if (!isset($this->_templates[$type])) {
			$this->_templates[$type] = new Zend_Loader_PluginLoader();
		}

		$this->_templates[$type]->addPrefixPath(trim($prefix, "_"), $dir, $type);
		return $this;
	}
	
	public function getNameGrid() {
		return $this->_gridName;
	}

	public function setNameGrid($gridName) {
		$this->_gridName = $gridName;
	}

	protected function _buildGridTable($grids) {
		return '<tbody>' . parent::_buildGridTable($grids) . '</tbody>';
	}

	protected function _pagination() {
		return strtr(parent::_pagination(), array('&nbsp;' => ''));
	}

}